home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 208 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.4 KB

  1. From: clamage@Eng.Sun.COM (Steve Clamage)
  2. Message-ID: <4epod1$qth@engnews1.Eng.Sun.COM>
  3. X-Original-Date: 1 Feb 1996 06:59:45 GMT
  4. Path: in1.uu.net!bounce-back
  5. Date: 01 Feb 96 13:18:50 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: When can definitions of library functions be provided by a program?
  9. Organization: Sun Microsystems Inc., Mountain View, CA
  10. References: <DM2Bv9.C7p@scr.siemens.com>
  11. X-Newsreader: NN version 6.5.0 #21 (NOV)
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBFAgUBMRC92uEDnX0m9pzZAQE67AF/ZWmecW/HPW/Rwir41ByvGcDm6QH2svi1
  14.     XyqjuS+F9HgiVvhA7PbaOPIvMr0WyGn9
  15.     =LPat
  16.  
  17. mlg@scr.siemens.com (Michael Greenberg) writes:
  18.  
  19. >I'm trying to figure out under what circumstances a program can supply
  20. >a definition for a library function.  Is it the case that a program
  21. >cannot supply a definition for any library function except for those
  22. >listed in 17.3.3.4 (new & delete with various signatures)?
  23.  
  24. That is correct. You cannot extend the "std" namespace, and the names
  25. of the library functions are reserved except as noted.
  26.  
  27. The reason for the rule is to ensure 3rd-party libraries, and indeed the
  28. implementation-supplied runtime library, can depend on the operation
  29. of the standard functions. If you were allowed to replace them, there
  30. could be no guarantees. (It also allows implementors maximum
  31. freedom in implementing the library, since replacing functions
  32. need not be considered.)
  33.  
  34. Example: A program used in religious education has a function that
  35. analyzes answers to moral questions via an index and determines the
  36. degree of "sin" involved. If the function were called "sin", that
  37. could create havoc in other parts of the program that attempted to do
  38. trigonometric calculations.
  39.  
  40. The rule does not mean an implementation must prevent you from
  41. trying to replace library functions. Indeed, it is often
  42. possible to do so for selected functions. You just cannot depend
  43. on being able to do it, particularly in portable code. Such a
  44. program might not compile, might compile but not link, might
  45. link but not run correctly.
  46.  
  47. >(As an aside, what's the 'C' standard have to say about this?)
  48.  
  49. No functions in the C library may be replaced. All the names are
  50. reserved.
  51. --
  52. Steve Clamage, stephen.clamage@eng.sun.com
  53. ---
  54. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  55.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  56.   is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
  57.